{extend name="shared/layout" /}
{block name="title"}修改小程序{/block}
{block name="css"}
    <link href="/static/sys/css/skin_0.css" rel="stylesheet" />    
{/block}
{block name="javascript"}    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#ok").bind("click", Save);
            $("#cancel").bind("click", function () {
                parent.layer.close(parent.layer_edit_index);
            });
            $(".cb-enable").click(function () {
                var parent = $(this).parents('.onoff');
                $('.cb-disable', parent).removeClass('selected');
                $(this).addClass('selected');
                $('.checkbox', parent).attr('checked', true);
            });
            $(".cb-disable").click(function () {
                var parent = $(this).parents('.onoff');
                $('.cb-enable', parent).removeClass('selected');
                $(this).addClass('selected');
                $('.checkbox', parent).attr('checked', false);
            });            
        })
       
        function Save() {
            layui.use(['layer'], function(){
                var layer = layui.layer;

                var name = $.trim($("input[name=name]").val());
                if (name.length == 0) {
                    layer.tips('微信小程序名称不能为空！', 'input[name=name]', { tips: [2, '#78BA32'] });
                    return false;
                }
                var original_id = $.trim($("input[name=original_id]").val());
                if (original_id.length == 0) {
                    layer.tips('微信小程序original_id不能为空！', 'input[name=original_id]', { tips: [2, '#78BA32'] });
                    return false;
                }
                
                

                var load_index = layer.load(0, { shade: false });
                $.ajax({
                    type: "post",
                    url: "{:url('manager/edit')}?t=" + new Date(),
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (result) {
                        layer.close(load_index);
                        if (result.code == 0) {
                            layer.alert('保存成功！', function () {
                                if (typeof (parent.initTable) == "function")
                                    parent.initTable();
                                parent.layer.close(parent.layer_edit_index)
                            });
                        } else {
                            layer.alert(result.msg);
                        }
                    }
                });
            });
        }
    </script>
{/block}
{block name="content"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form method="post" id="fmNew" class="form-horizontal">
                            <input type="hidden" name="id" value="{$data.id}" />
                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序名称：</label>
                                <div class="col-sm-4">
                                    <input type="text" id="txtname" name="name" class="form-control" placeholder="请输入小程序名称" value="{$data.name}" />
                                </div>                                                                
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序OriginalId</label>
                                <div class="col-sm-4">
                                    <input type="text" name="original_id" id="txtoriginal_id" class="form-control" placeholder="请输入小程序OriginalId" value="{$data.original_id}" />
                                </div>                                
                            </div>                            
                            <div class="form-group">                                
                                <label class="col-sm-2 control-label">跳转小程序：</label>
                                <div class="col-sm-1 onoff" style="padding-top:4px;">
                                    <label for="isjump1" class="cb-enable {if condition='$data.isjump eq 1'}selected{/if}"><span>是</span></label>
                                    <label for="isjump0" class="cb-disable {if condition='$data.isjump eq 0'}selected{/if}"><span>否</span></label>
                                    <input id="isjump1" name="isjump" value="1" {if condition="$data.isjump eq 1"}checked="checked"{/if} type="radio" />
                                    <input id="isjump0" name="isjump" value="0" {if condition="$data.isjump eq 0"}checked="checked"{/if} type="radio" />
                                </div>
                                <label class="col-sm-2 control-label">跳转目标AppId</label>
                                <div class="col-sm-4">
                                    <input type="text" name="app_id" id="txtapp_id" class="form-control" placeholder="请输入目标小程序AppId" value="{$data.app_id}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">跳转地址</label>
                                <div class="col-sm-4">
                                    <input type="text" name="jump_url" id="txtjump_url" class="form-control" placeholder="请输入跳转目标小程序地址" value="{$data.jump_url}" />
                                </div>
                            </div>
                            <div class="form-group">                                
                                <label class="col-sm-2 control-label">显示审核壳：</label>
                                <div class="col-sm-1 onoff" style="padding-top:4px;">
                                    <label for="isshow1" class="cb-enable {if condition='$data.isshow eq 1'}selected{/if}"><span>是</span></label>
                                    <label for="isshow0" class="cb-disable {if condition='$data.isshow eq 0'}selected{/if}"><span>否</span></label>
                                    <input id="isshow1" name="isshow" value="1" {if condition="$data.isshow eq 1"}checked="checked"{/if} type="radio">
                                    <input id="isshow0" name="isshow" value="0" {if condition="$data.isshow eq 1"}checked="checked"{/if} type="radio">
                                </div>
                                <label class="col-sm-2 control-label">显示审核壳(备用)：</label>
                                <div class="col-sm-4 onoff" style="padding-top:4px;">
                                    <label for="isshowback1" class="cb-enable {if condition='$data.isshowback eq 1'}selected{/if}"><span>是</span></label>
                                    <label for="isshowback0" class="cb-disable {if condition='$data.isshowback eq 0'}selected{/if}"><span>否</span></label>
                                    <input id="isshowback1" name="isshowback" value="1" {if condition="$data.isshowback eq 1"}checked="checked"{/if} type="radio">
                                    <input id="isshowback0" name="isshowback" value="0" {if condition="$data.isshowback eq 0"}checked="checked"{/if} type="radio">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-12 col-sm-offset-5">
                                    <button class="btn btn-primary" id="ok" type="button">提交</button>
                                    <button class="btn btn-white" id="cancel" type="button">取消</button>
                                </div>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>        
{/block}